<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="100px">
      <el-form-item label="申请单编号">
        <el-input
          v-model="queryParams.applyNo"
          placeholder="请输入申请单编号"
          clearable
          size="small"
          style="width: 120%"
        />
      </el-form-item>
      <el-form-item label="申请状态" style="margin-left: 20px;">
        <el-select
          style="width: 100%;"
          v-model="queryParams.applyStatus"
          @change="checkDor"
          clearable
        >
          <el-option
            v-for="(item,index) in applyStatusList"
            :key="index"
            :label="item.text"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8" v-if="activeName == 'first'">
      <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">创建未归寝申请单</el-button>
    </el-row>
    <!-- 第一个tab页 -->
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="申请单列表" name="first">
        <el-table :data="deployList">
          <el-table-column label="申请单编号" prop="applyNo" align="center"></el-table-column>
          <el-table-column label="学生姓名" prop="studentName" align="center"></el-table-column>
          <el-table-column label="学生照片" prop="studentImg" align="center">
            <template slot-scope="scope">
              <img style="width: 50%; height:50%" :src="scope.row.studentImg" alt />
            </template>
          </el-table-column>
          <el-table-column label="宿舍名称" prop="className" align="center"></el-table-column>
          <el-table-column label="未归日期" prop="notRetrunedDate" align="center"></el-table-column>
          <el-table-column label="未归原因" prop="reason" align="center"></el-table-column>
          <el-table-column label="当前审批人" prop="currentApprover" align="center"></el-table-column>
          <el-table-column label="当前审批节点" prop="currentNode" align="center"></el-table-column>
          <el-table-column label="申请单状态" prop="applyStatus" align="center">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.applyStatus==0" type="waring">申请被驳回</el-tag>
              <el-tag v-if="scope.row.applyStatus==1" type="primary">审批中</el-tag>
              <el-tag v-if="scope.row.applyStatus==2" type="danger">申请被撤回</el-tag>
              <el-tag v-if="scope.row.applyStatus==10" type="success">审批通过</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="创建时间" prop="createTime" align="center">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" prop="handle" align="center">
            <template slot-scope="scope">
              <el-button
                v-if="scope.row.applyStatus == 1"
                size="mini"
                icon="el-icon-refresh-right"
                type="warning"
                circle
                @click="cancelApply(scope.row)"
              ></el-button>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getPageList"
        />
      </el-tab-pane>
      <!-- 第二个tab -->
      <el-tab-pane label="待审批列表" name="second">
        <el-table :data="pendApprovalList">
          <el-table-column
            label="申请单编号"
            prop="applyNo"
            align="center"
            :show-overflow-tooltip="true"
            width="180px"
          ></el-table-column>
          <el-table-column
            label="学生姓名"
            align="center"
            prop="studentName"
            :show-overflow-tooltip="true"
          />
          <el-table-column label="学生照片" align="center" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <img style="width: 50%; height:50%" :src="scope.row.studentImg" alt />
            </template>
          </el-table-column>

          <el-table-column label="宿舍名称" align="center" prop="sdId" :show-overflow-tooltip="true" />
          <el-table-column
            label="未归寝日期"
            align="center"
            prop="notRetrunedDate"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="未归寝原因"
            align="center"
            prop="reason"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="当前审批人"
            align="center"
            prop="currentApprover"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="审批节点"
            align="center"
            prop="currentNode"
            :show-overflow-tooltip="true"
          />
          <el-table-column label="申请单状态" prop="applyStatus" align="center">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.applyStatus==0" type="waring">申请被驳回</el-tag>
              <el-tag v-if="scope.row.applyStatus==1" type="primary">审批中</el-tag>
              <el-tag v-if="scope.row.applyStatus==2" type="danger">申请被撤回</el-tag>
              <el-tag v-if="scope.row.applyStatus==10" type="success">审批通过</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="创建时间" prop="createTime" align="center">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center">
            <template slot-scope="scope">
              <el-button
                icon="el-icon-edit"
                size="mini"
                circle
                type="sucess"
                v-if="scope.row.applyStatus==1"
                @click="openApprovalDialog(scope.row)"
              ></el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="totalAppro>0"
          :total="totalAppro"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getPendingList"
        />
      </el-tab-pane>
      <!-- 第三个 -->
      <el-tab-pane label="已完成审批列表" name="third">
        <el-table :data="processList">
          <el-table-column label="审批节点" prop="businessData.applyNo" align="center"></el-table-column>
          <el-table-column label="学生姓名" prop="businessData.studentName" align="center"></el-table-column>
          <el-table-column label="学生照片" prop="businessData" align="center">
            <template slot-scope="scope">
              <img style="width: 50%; height:50%" :src="scope.row.businessData.studentImg" />
            </template>
          </el-table-column>
          <el-table-column label="宿舍名称" prop="businessData.sdId" align="center"></el-table-column>
          <el-table-column label="未归日期" prop="businessData.notRetrunedDate" align="center"></el-table-column>
          <el-table-column label="未归原因" prop="businessData.reason" align="center"></el-table-column>
          <el-table-column label="审批节点" prop="name" align="center"></el-table-column>
          <el-table-column label="申请单状态" prop="businessData.applyStatus" align="center">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.businessData.applyStatus==0" type="waring">申请被驳回</el-tag>
              <el-tag v-if="scope.row.businessData.applyStatus==1" type="primary">审批中</el-tag>
              <el-tag v-if="scope.row.businessData.applyStatus==2" type="danger">申请被撤回</el-tag>
              <el-tag v-if="scope.row.businessData.applyStatus==10" type="success">审批通过</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="创建时间" prop="createTime" align="center">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" prop="createTime" align="center">
            <template slot-scope="scope">
              <el-button
                size="mini"
                icon="el-icon-view"
                circle
                @click="wtachDetail(scope.row.businessData)"
              ></el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>

    <!-- 创建申请单的dialog -->
    <el-dialog title="创建请假申请" @close="closeDialog" :visible.sync="dialogVisible" width="70%">
      <el-form :model="leaveFormData" ref="leaveFormData" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="8">
            <el-form-item required name="sdId" label="宿舍号" prop="sdId">
              <el-select v-model="leaveFormData.sdId" @change="checkDor"  filterable clearable>
                <el-option
                  v-for="item in dorList"
                  :key="item.id"
                  :label="(item.buildingNname + item.dormitoryNo)"
                  :value="item.dormitoryNo"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item required name="studentId" label="学生姓名" prop="studentId">
              <el-select @change="checkStu" v-model="leaveFormData.studentId" clearable>
                <el-option
                  v-for="item in studentNameList"
                  :key="item.id"
                  :label="item.studentName"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="未归寝日期" prop="notRetrunedDate">
              <!-- <el-date-picker
                :disabled="isView"
                v-model="leaveFormData.notRetrunedDate"
                type="datetime"
                value-format="yyyy-MM-dd"
                :picker-options="expireTimeOPtion"
                placeholder="选择未归寝日期时间"
                
              ></el-date-picker>-->
              <el-date-picker
                style="width: 60%;"
                v-model="leaveFormData.notRetrunedDate"
                value-format="yyyy-MM-dd"
                type="date"
                placeholder="选择未归寝日期"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="rowShow">
          <el-col :span="8">
            <el-form-item label="学生照片" prop="studentImg">
              <img style="width: 50%; height:50%" :src="studentImg" alt />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="班主任" prop="teacherName">
              <el-input style="width: 60%;" v-model="teacherName" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="班级名称" prop="className">
              <el-input style="width: 60%;" v-model="className" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="未归寝原因" name="reason" required>
              <el-input
                type="textarea"
                style="width: 100%;"
                v-model="leaveFormData.reason"
                :disabled="isView"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-button style="margin-left:83.33%" @click="cancle">取 消</el-button>
      <el-button type="primary" @click="submit">提 交</el-button>
    </el-dialog>

    <!-- 审批的dialog -->
    <el-dialog title="审批" @close="closeDialog" :visible.sync="approDialogVisible" width="70%">
      <el-form ref="approvalForm" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="8">
            <el-form-item name="sdId" label="宿舍号">
              <el-input v-model="approvalForm.sdId" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item name="studentId" label="学生姓名">
              <el-input v-model="approvalForm.studentName" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="未归寝日期" prop="notRetrunedDate">
              <el-date-picker
                type="datetime"
                value-format="yyyy-MM-dd"
                :picker-options="expireTimeOPtion"
                v-model="approvalForm.notRetrunedDate"
                disabled
                style="width: 100%;"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="学生照片" prop="studentImg">
              <img :src="approvalForm.studentImg" style="width: 50%; height:50%" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="班主任" prop="teacherName">
              <el-input v-model="approvalForm.teacherName" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="班级名称" prop="className">
              <el-input v-model="approvalForm.className" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="未归寝原因" name="reason">
              <el-input v-model="approvalForm.reason " disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!-- 流程组件 -->
      <approvalHistory v-if="pathShow" :processId="processId"></approvalHistory>
      <el-divider content-position="left" v-if="activeName=='second'">审批</el-divider>
      <!-- 表单 -->
      <!--班主任处理-->
      <el-form v-model="workflowformData" :rules="approRules" ref="workflowformData" v-if="rejectShow == 'classTeacherHandle'">
        <el-form-item label="审批状态" name="flag" required>
          <el-radio label="2" v-model="workflowformData.flag">忘记提交请假</el-radio>
          <el-radio label="1" v-model="workflowformData.flag">学生在宿舍</el-radio>
          <el-radio label="0" v-model="workflowformData.flag">提交到部门经理处理</el-radio>
        </el-form-item>
        <el-form-item label="审批意见" name="applyDesc" required>
          <el-input v-model="workflowformData.applyDesc" type="textarea" style="width:90%"></el-input>
        </el-form-item>
      </el-form>
      <!--部门经理处理-->
      <el-form v-model="workflowformData" :rules="approRules" ref="workflowformData" v-if="rejectShow == 'deptManageHandle'">
        <el-form-item label="审批状态" name="flag" required>
          <el-radio label="1" v-model="workflowformData.flag">已处理</el-radio>
        </el-form-item>
        <el-form-item label="审批意见" name="applyDesc" required>
          <el-input v-model="workflowformData.applyDesc" type="textarea" style="width:90%"></el-input>
        </el-form-item>
      </el-form>
      <!--宿管确认处理-->
      <el-form v-model="workflowformData" :rules="approRules" ref="workflowformData" v-if="rejectShow == 'presenterHandle'">
        <el-form-item label="审批状态" name="flag" required>
          <el-radio label="1" v-model="workflowformData.flag">已确认处理</el-radio>
          <el-radio label="0" v-model="workflowformData.flag">学生还未归寝</el-radio>
        </el-form-item>
        <el-form-item label="审批意见" name="applyDesc" required>
          <el-input v-model="workflowformData.applyDesc" type="textarea" style="width:90%"></el-input>
        </el-form-item>
      </el-form>

      <el-button style="margin-left:83.33%" @click="cancleAppro">取 消</el-button>
      <el-button type="primary" @click="submitAppro">提 交</el-button>
    </el-dialog>
    <!-- 审批流程 -->
    <el-dialog title="流程审批" @close="closeDialog" :visible.sync="detailShow" width="70%">
      <el-form ref="detailForm" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="8">
            <el-form-item name="sdId" label="宿舍号">
              <el-input v-model="detailForm.sdId" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item name="studentId" label="学生姓名">
              <el-input v-model="detailForm.studentName" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="未归寝日期" prop="notRetrunedDate">
              <el-date-picker
                type="datetime"
                value-format="yyyy-MM-dd"
                :picker-options="expireTimeOPtion"
                v-model="detailForm.notRetrunedDate"
                disabled
                style="width: 100%;"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="学生照片" prop="studentImg">
              <img :src="detailForm.studentImg" style="width: 50%; height:50%" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="班主任" prop="teacherName">
              <el-input v-model="detailForm.teacherName" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="班级名称" prop="className">
              <el-input v-model="detailForm.className" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="未归寝原因" name="reason">
              <el-input v-model="detailForm.reason " disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <!-- 流程组件 -->
      <approvalHistory v-if="detailApproval" :processId="detailProcessId"></approvalHistory>
      <el-button style="margin-left:93%" @click="cancleDetail">关 闭</el-button>
    </el-dialog>
  </div>
</template>

<script>
import {
  listBDormitory,
  getPageList,
  creatApply,
  getStudentById,
  getDictType,
  cancelApply,
  processWorkFlow,
  workFlowInfo,
  findHistoryApproval
} from "@/api/workflow/notRetrunedApply";
import { listBStudent } from "@/api/basedata/bstudent";
import approvalHistory from "@/components/workFlow/approvalHistory";
export default {
  components: {
    approvalHistory
  },
  data() {
    return {
      detailProcessId: "",
      detailApproval: false,
      detailForm: {
        sdId: "",
        studentName: "",
        notRetrunedDate: "",
        studentImg: "",
        reason: ""
      },
      detailShow: false,
      // 已经处理过的工作流
      processList: [],
      pathShow: false,
      totalAppro: 0,
      processId: "",
      activeName: "first",
      isView: false,
      expireTimeOPtion: {
        disabledDate(time) {
          return time.getTime() <= Date.now() - 1 * 24 * 3600 * 1000; //如果没有后面的-8.64e7就是不可以选择今天的
        }
      },
      rowShow: false,
      // 学生照片
      studentImg: "",
      loading: true,
      // 查询表单参数
      queryParams: {
        // 申请单编号
        applyNo: "",
        // 申请状态
        applyStatus: "",
        pageNum: 1,
        pageSize: 10
      },
      // 请假类型
      leaveTypeList: [],
      // 表格数据
      deployList: [],
      // 新建的表单参数
      leaveFormData: {
        // 宿舍id
        sdId: "",
        // 学生id
        studentId: "",
        // 班级id
        classId: "",
        // 未归寝日期
        notRetrunedDate: "",
        // 为归寝原因
        reason: "",
        //
        applyStatus: "1",
        //
        applyId: "notRetrunApplyNew"
      },
      // dialog
      dialogVisible: false,
      // 审批的dialog
      approDialogVisible: false,
      // 宿舍号数组
      dorList: [],
      // 学生列表
      studentNameList: [],
      // 班级姓名
      className: "",
      // 班主任
      teacherName: "",
      // 规则
      rules: {
        reason: [
          { required: true, message: "请填未归寝原因", trigger: "change" }
        ],
        sdId: [{ required: true, message: "请选择宿舍号", trigger: "change" }],
        studentId: [
          { required: true, message: "请选择学生", trigger: "change" }
        ]
      },
      // 审批状态
      applyStatusList: [
        {
          text: "申请被驳回",
          value: 0
        },
        {
          text: "审批中",
          value: 1
        },
        {
          text: "申请被撤回",
          value: 2
        },
        {
          text: "审批通过",
          value: 10
        }
      ],
      total: 0,
      // 待审批处理
      pendApprovalList: [],
      // 审批表单
      workflowformData: {
        flag: "",
        applyDesc: "",
        processInstanceId: ""
      },
      // approvalForm
      approvalForm: {
        sdId: "",
        studentName: "",
        notRetrunedDate: "",
        studentImg: "",
        reason: ""
      },
      approRules: {
        flag: [
          { required: true, message: "请选择审批状态", trigger: "change" }
        ],
        applyDesc: [
          { required: true, message: "请填写审批意见", trigger: "change" }
        ]
      },
      workInfo: {},
      rejectShow: ""
    };
  },
  methods: {
    // 撤销申请
    cancelApply(row) {
      this.$confirm("确认撤销申请", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        cancelApply({
          processInstanceId: row.processInstanceId
        }).then(res => {
          console.log(res);
          if (res.code == 200) {
            this.$message({
              message: "撤销成功",
              type: "success"
            });
            this.getPageList();
          }
        });
      });
    },
    // 清空创建申请表单
    rest() {
      this.leaveFormData = {
        sdId: "",
        studentId: "",
        classId: "",
        notReturnDate: "",
        reason: "",
        applyStatus: "1",
        applyId: "notRetrunApplyNew"
      };
      this.className = "";
      this.teacherName = "";
      this.studentImg = "";
      this.rowShow = false;
    },
    resetAppro() {
      this.workflowformData = {
        flag: "",
        applyDesc: "",
        processInstanceId: "",
        taskId: ""
      };
      this.rejectShow = "";
    },
    // 搜索查询
    handleQuery() {
      getPageList({
        applyNo: this.queryParams.applyNo,
        applyStatus: this.queryParams.applyStatus,
        pageNum: 1,
        pageSize: 10,
        type: "1"
      }).then(res => {
        this.deployList = res.data.list;
        this.total = res.data.total;
      });

      getPageList({
        applyNo: this.queryParams.applyNo,
        applyStatus: this.queryParams.applyStatus,
        pageNum: 1,
        pageSize: 10,
        type: "2"
      }).then(res => {
        this.totalAppro = res.data.total;
        this.pendApprovalList = res.data.list;
        console.log(this.pendApprovalList);
      });
    },
    // 重置查询
    resetQuery() {
      this.queryParams.applyNo = "";
      this.queryParams.applyStatus = "";
    },
    // 新增未归寝申请
    handleAdd() {
      this.rest();
      this.dialogVisible = true;
      getDictType("sys_building").then(res => {
        this.dorList.forEach(item => {
          res.data.forEach(e => {
            if (item.buildingNo == e.dictValue) {
              //   item.buildingNname = e.dictLabel;
              this.$set(item, "buildingNname", e.dictLabel);
            }
          });
        });
        console.log(this.dorList);
      });
    },
    // 查询宿舍列表
    getBdormitoryList() {
      listBDormitory({
        pageNum: 1,
        pageSize: 1000
      }).then(res => {
        this.dorList = res.data.list;
        console.log(this.dorList);
      });
    },
    // 查询表格列表
    getPageList() {
      getPageList({
        applyNo: "",
        applyStatus: "",
        pageNum: 1,
        pageSize: 10,
        type: "1"
      }).then(res => {
        this.deployList = res.data.list;
        this.total = res.data.total;
      });
    },
    // 选择宿舍号显示学生名称
    checkDor(e) {
      this.leaveFormData.studentId = "";
      console.log(this.studentNameList);
      listBStudent({
        pageNum: 1,
        pageSize: 10,
        dormitoryNo: e
      }).then(res => {
        this.studentNameList = res.data.list;
        console.log(this.studentNameList);
      });
    },
    // 选择学生 查到学生信息
    checkStu(e) {
      getStudentById(e).then(res => {
        console.log(res);
        this.className = res.data.className;
        this.leaveFormData.classId = res.data.classId;
        this.teacherName = res.data.teacherName;
        this.studentImg = res.data.stuPhoto;
        this.rowShow = true;
      });
    },
    // 取消按钮
    cancle() {
      this.dialogVisible = false;
      this.$refs.leaveFormData.resetFields();
    },
    // 提交申请
    submit() {
      this.$refs["leaveFormData"].validate(valid => {
        if (valid) {
          creatApply(this.leaveFormData).then(res => {
            console.log(res);
            if (res.code == 200) {
              this.$message({
                message: "提交成功",
                type: "success"
              });
              this.dialogVisible = !this.dialogVisible;
              this.rest();
              this.getPageList();
              this.getPendingList();
              this.$refs.leaveFormData.resetFields();
            }
          });
        }
      });
    },
    closeDialog() {
      console.log(123);
      this.detailApproval = false;
      this.pathShow = false;
    },
    handleClick(e) {
      console.log(e.index);
      if (e.index == 0) {
        this.getPageList();
      } else if (e.index == 1) {
        this.getPendingList();
      } else if (e.index == 2) {
        this.findHistoryApproval();
      }
    },
    // 审批按钮
    handleApply() {},
    // 审批的dialog
    closeApproDialog() {},
    openApprovalDialog(row) {
      this.approDialogVisible = true;
      this.pathShow = true;
      console.log(this.pathShow);

      this.approvalForm = row;
      this.processId = row.processInstanceId;
      workFlowInfo({
        processInstanceId: row.processInstanceId
      }).then(res => {
        this.workInfo = res.data;
        this.rejectShow = res.data.currNode;
      });
      getStudentById(row.studentId).then(res => {
        this.$set(this.approvalForm, "teacherName", res.data.teacherName);
      });
    },
    // 查看按钮
    wtachDetail(row) {
      this.detailShow = true;
      this.detailApproval = true;
      this.detailForm = row;
      this.detailProcessId = row.processInstanceId;
      getStudentById(row.studentId).then(res => {
        this.$set(this.detailForm, "teacherName", res.data.teacherName);
      });
    },
    // 查询待审批申请列表
    getPendingList() {
      getPageList({
        pageNum: 1,
        pageSize: 10,
        type: "2"
      }).then(res => {
        this.totalAppro = res.data.total;
        this.pendApprovalList = res.data.list;
        console.log(this.pendApprovalList);
      });
    },
    // 审批的dialog取消
    cancleAppro() {
      this.pathShow = false;
      this.approDialogVisible = false;
      this.resetAppro();
    },
    // 审批dialog提交
    submitAppro() {
      this.workInfo.flag = this.workflowformData.flag;
      this.workInfo.applyDesc = this.workflowformData.applyDesc;
      processWorkFlow(this.workInfo).then(res => {
        console.log(res);
        if (res.code == 200) {
          this.$message({
            message: "提交成功",
            type: "success"
          });
          this.getPageList();
          this.getPendingList();
          this.resetAppro();
          this.approDialogVisible = false;
        }
      });
    },
    // 获取已经处理过的工作流
    findHistoryApproval() {
      findHistoryApproval({
        pageNum: 1,
        pageSize: 10,
        applyID: "notRetrunApplyNew"
      }).then(res => {
        console.log(res);
        this.processList = res.data.list;
      });
    },
    cancleDetail() {
      this.detailShow = false;
      this.detailApproval = false;
      console.log(this.detailApproval);
    }
  },
  mounted() {
    this.getBdormitoryList();
    this.getPageList();
    this.getPendingList();
    this.findHistoryApproval();
  }
};
</script>
  